package com.init;

import kafka.common.KafkaException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.kafka.SendDataToKafkaProducer;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

//2.创建三个类，使用@Component注解将其交给Spring容器自动加载,每个类分别加上@Order(1)、@Order(2)、@Order(3)注解
//https://www.1024sky.cn/blog/article/521  @Order(1) 1.AOP加载顺序（切面加载顺序   2.配置类加载顺序
@Component
@Order(1)
public class InitConfig implements CommandLineRunner {
    final static Logger logger = LoggerFactory.getLogger(InitConfig.class);
    public static SendDataToKafkaProducer simpleKafkaProducer;//初始化


    @Override
    public void run(String... args) throws Exception {
        try {
            simpleKafkaProducer = new SendDataToKafkaProducer();
            logger.info("begin 设置SendDataToKafkaProducer 为全局变量");
        }catch (KafkaException e){
            e.printStackTrace();
        }
    }

}
